﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
namespace Common
{
public	class MDPException : ApplicationException
	{
		 //异常编码
        private string _code;
        private string _message;

        /// <summary>
        /// 异常编码
        /// </summary>
        public virtual string Code
        {
            get { return _code; }
            set { _code = value; }
        }

        public virtual string Message
        {
            get { return _message; }
            set { _message = value; }
        }

        #region 构造函数

        public MDPException()
        {
        }

        public MDPException(Exception innerMessage)
            : base("", innerMessage)
        { 
        }

        public MDPException(string code, Exception innerException)
        {
            HttpContext.Current.Response.Redirect("~/Errors/Error.html");
            _code = code;
            _message = GetMessage(code);
        }

		public MDPException(string code)
            : this(code, null)
        {
            //HttpContext.Current.Response.Redirect("~/error/error.html");
        }

        protected virtual string GetMessage(string code)
        {
            //没有实现
            //if (ExceptionRecs.ResourceManager != null)
            //{
            //    try
            //    {
            //        //return ExceptionRecs.ResourceManager.GetString(code);
            //        return ExceptionRecsNew.ResourceManager.GetString(code);
            //    }
            //    catch
            //    {
            //        return code;
            //    }
            //}

            //if (InnerException != null)
            //{
            //    return InnerException.Message;
            //}

            //return "出现{0}异常!";
            return code;
        }

        //调用此方法可以得到异常消息页面的文件路径
        public virtual string GetMessageFile()
        {
            //IDictionary idFilePath = (IDictionary)ConfigurationManager.GetConfig("FilePath");
            //string filePath = (string)idFilePath["settingPath"];
            string filePath = "asdfasd";
            return filePath;
        }

        #endregion

	}
}
